import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class a3{
    public static Map<String,Integer> mp=new HashMap();
    /**
     * 计算字符评分
     */
    public static int calc(String s){
        if(mp.containsKey(s)){
            return mp.get(s);
        }
        Stack<Character> st=new Stack<>();
        int n=s.length();
        if(0==n){
            return 0;
        }
        int dmax=0;
        for(int i=0;i<n;i++){
            char c=s.charAt(i);
            if(st.size()>0 && c==')' && st.peek()=='('){
                st.pop();
            }else{
                st.push(c);
            }
            dmax=Math.max(dmax,st.size());
        }
        //dmax=Math.max(dmax,st.size());
         //System.out.println(s+" "+dmax);
        
        if(st.size()==0){
            return dmax;
        }else{
            return -st.size();
        }
    }

    public static void main(String[] args) {
        try {
          
            List<Integer> ans=new ArrayList<>();
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int n = Integer.parseInt(br.readLine());
            String s =br.readLine();
            StringBuffer sb=new StringBuffer();
            int i=0,index=0;
            for(i=0,index=0;i<n;i++){
                char c=s.charAt(i);
                if(c=='('||c==')'){
                    sb.insert(index,c);
                    index++;
                }else if(c=='D'){
                    index--;
                    sb.deleteCharAt(index); 
                }else if(c=='L'){
                    index=(index-1)<0?0:index-1;
                }else if(c=='R'){
                    int le=sb.length();
                    index=index+1>le?le:index+1;
                }
               // System.out.println(sb.toString());
                mp.put(sb.toString(),calc(sb.toString()));
                ans.add(mp.get(sb.toString()));
            }
            for(int x : ans){
                System.out.print(x+" ");
            }
            System.out.println();

        } catch (Exception e) {
            //TODO: handle exception
        }
        
    }




}